package cn.nexd.app.collector.application;

import android.app.Application;
import android.os.Environment;

import com.android.volley.RequestQueue;
import com.android.volley.toolbox.Volley;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import cn.nexd.app.collector.BuildConfig;
import cn.nexd.app.collector.model.CollectConfig;
import cn.nexd.app.collector.presenter.db.NexdSqlOpenHelper;
import cn.nexd.app.collector.util.PgyUtil;
import cn.nexd.app.collector.util.UMengUtil;
import cn.nexd.utils.framework.tools.Logger;
import cn.nexd.utils.framework.tools.SDCardUtil;


/**
 * Created by xun on 2016/8/4.
 */
public class NexdApplication extends Application {
    private static NexdApplication nexdApplication;
    private NexdSqlOpenHelper sqlHelper;
    private List<CollectConfig> collectConfigs = new ArrayList<>();
    public static List<String> operaRecord; // 操作记录, 记录最终生成的zip包名称.


    public static final String BASE_FILE_PATH = Environment.getExternalStorageDirectory() + File.separator + "nexd" + File.separator + "collect";

    public static final String BASE_EXPORT_FILE_PATH = SDCardUtil.getSDCardPath() + File.separator + "nexd/export/";

    public List<CollectConfig> getCollectConfigs() {
        return collectConfigs;
    }

    public static NexdApplication getInstance() {
        return nexdApplication;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        nexdApplication = this;
        Logger.isDebug(BuildConfig.DEBUG);
        operaRecord = new ArrayList<>();

//        LeakCanary.install(this);
        UMengUtil.getInstance().init(this);
        PgyUtil.getInstance().register(this);
    }

    public RequestQueue getRequestQueue() {
        RequestQueue requestQueue = Volley.newRequestQueue(nexdApplication);
        requestQueue.start();
        return requestQueue;
    }

    public NexdSqlOpenHelper getSqlHelper() {
        if (sqlHelper == null) {
            sqlHelper = new NexdSqlOpenHelper(this);
        }
        return sqlHelper;
    }
}
